System.String.Concat 方法 (IEnumerable)
方法描述
串联 IEnumerable
语法定义(C# System.String.Concat 方法 (IEnumerable) 的用法)
[ComVisibleAttribute(false)] public static string Concat( IEnumerable values )
参数/返回值
| 参数值/返回值 | 参数类型/返回类型 | 参数描述/返回描述 |
|---|---|---|
| values | System-Collections-Generic-IEnumerable |
一个实现 IEnumerable |
| 返回值 | System.String | values 中的串联成员。 |
提示和注释
该方法连接 values 中的每个对象;它不添加任何分隔符。
使用 Empty 字符串替代任何 null 参数。
Concat
System.String.Concat 方法 (IEnumerable)例子
结果传递给 Concat
using System;
using System.Collections.Generic;
using System.Linq;
public class Animal
{
public string Kind;
public string Order;
public Animal(string kind, string order)
{
this.Kind = kind;
this.Order = order;
}
public override string ToString()
{
return this.Kind;
}
}
public class Example
{
public static void Main()
{
List animals = new List();
animals.Add(new Animal("Squirrel", "Rodent"));
animals.Add(new Animal("Gray Wolf", "Carnivora"));
animals.Add(new Animal("Capybara", "Rodent"));
string output = String.Concat(animals.Where( animal =>
(animal.Order == "Rodent")));
Console.WriteLine(output);
}
}
// The example displays the following output:
// SquirrelCapybara
异常
| 异常 | 异常描述 |
|---|---|
| ArgumentNullException | values 为 null。 |
版本信息
.NET Framework 受以下版本支持:4 .NET Framework Client Profile 受以下版本支持:4
适用平台
Windows 7, Windows Vista SP1 或更高版本, Windows XP SP3, Windows Server 2008(不支持服务器核心), Windows Server 2008 R2(支持 SP1 或更高版本的服务器核心), Windows Server 2003 SP2 .NET Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。